<template>
  <ContainerGroup>
    <Container height="fill" :scroll-y="true" display="flexY">
      <FilterForm
        ref="filterForm"
        style="margin-bottom:20px;"
        :elements="filterElements"
      >
        <Button
          style="display: inline-block;"
          @click="handleJc"
        >检查</Button>
      </FilterForm>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="科室-工资对应" name="first" />
        <el-tab-pane label="科室-HIS科室" name="second" />
        <el-tab-pane label="科室-用友科室" name="third" />
        <el-tab-pane label="成本-用友系统" name="four" />
        <el-tab-pane label="收入-用友系统" name="five" />
      </el-tabs>
      <div class="table-wraper">
        <!-- <div class="title">校验结果</div>
        <div v-loading="loading" class="list-box">
          <template v-if="listData.length>0">
            <div v-for="(item,index) in listData" :key="index" class="block">{{ item }}</div>
          </template>
          <template v-if="checkReult">
            <div class="block"> {{ name }}检验通过</div>
          </template>
        </div> -->
        <el-table
          v-loading="isDialog"
          :data="tableDataDialog"
          border
          :header-cell-style="{ background: '#fafafa', borderColor: '#e7ecf8' }"
          header-row-class-name="ck-table-header"
          row-class-name="ck-table-row"
          size="small"
          height="100%"
        >
          <el-table-column align="center" type="index" label="序号" width="60" />
          <el-table-column
          v-for="(item,index) in dycColumn" :key="index"
            :prop="item.prop"
            :label="item.label"
          />
        </el-table>
      </div>
    </Container>
  </ContainerGroup>
</template>

<script>
import { BasicParams } from "../../../utils/basicParams";
import { YySysterm } from "../../../utils/yySysterm";
import {
  getRubbing1,
  getRubbing2,
  getRubbing3
} from '@/utils/apis/report'
import {
  listEnumDetailUnLink
} from '../../../utils/apis/accountingUnit/share.js'
import {
  getCheck
} from "../../../utils/apis/dataExchange/index";
export default {
  name: 'WorkingVerification',
  data() {
    return {
      tableDataDialog: [],
      isDialog: false,
      loading: false,
      checkReult: false,
      listData: [],
      activeName: 'first',
      name: '科室-工资对应',
      tableColumn: [
        {
          prop:'deptCode',
          label: '科室代码',
          width: ''
        },
        {
          prop:'deptName',
          label: '科室名称',
          width: ''
        }
      ],
      // filterElements: [
      //   {
      //     key: 'yearMonth',
      //     type: 'date-picker',
      //     label: '年/月',
      //     mode: 'month',
      //     format: 'yyyy-MM',
      //     value: this.$util.currentDate(),
      //     width: 210
      //   }
      // ]
    }
  },
  mounted() {
    setTimeout(() => {
      this.getData('RD_DeptSalaryRelation','Salary')
    }, 1000)
  },
  computed: {
    dycColumn(){
      if (this.activeName === 'first') {
        return this.tableColumn
      } else if (this.activeName === 'second') {
       return [{
          prop:'deptCode',
          label: 'HIS科室代码',
          width: ''
        },
        {
          prop:'deptName',
          label: 'HIS科室名称',
          width: ''
        }]
      } else if (this.activeName === 'third') {
        return [{
          prop:'deptCode',
          label: '用友科室代码',
          width: ''
        },
        {
          prop:'deptName',
          label: '用友科室名称',
          width: ''
        }]
      } else if (this.activeName === 'four') {
        return [{
          prop:'accountcode',
          label: '成本用友系统科室代码',
          width: ''
        },
        {
          prop:'accountname',
          label: '成本用友系统科室名称',
          width: ''
        }]
      } else {
         return [{
          prop:'accountcode',
          label: '收入用友系统科室代码',
          width: ''
        },
        {
          prop:'accountname',
          label: '收入用友系统科室名称',
          width: ''
        }]
      }
    }
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab)
      this.activeName = tab.name
      this.name = tab.label
      this.handleTab()
    },
    handleTab() {
       this.tableDataDialog = []
       this.isDialog = false
      if (this.activeName === 'first') {
        this.getData('RD_DeptSalaryRelation','Salary')
      } else if (this.activeName === 'second') {
       this.getData('RD_DeptHisRelation','HIS')
      } else if (this.activeName === 'third') {
        this.getData('RD_DeptUFIDARelation','UFIDA')
      } else if (this.activeName === 'four') {
        this.getYySysterm('Cost')
      } else {
         this.getYySysterm('Income')
      }
    },
    getYySysterm(sysid){
      let yySysterm = new YySysterm();
      yySysterm.accountcode = '';
      yySysterm.sysid = sysid;
      yySysterm.relationStatus = 0;
      this.isDialog = true
      getCheck(yySysterm).then((res) => {
         this.isDialog = false
        if (res.data.code == 200) {
          this.tableDataDialog = res.data.data;
        }
      });
      
    },
    getData(edParentCode,sysId) {
      // const fieldVal = this.$refs.filterForm.getParms()
      // const param = {
      //   year: fieldVal?.yearMonth.substr(0, 4),
      //   month: fieldVal?.yearMonth.substr(5)
      // }
      // this.listData = []
      // this.loading = true
      let basicParams = new BasicParams();
        basicParams.edParentCode = edParentCode;
        basicParams.sysId = sysId;
        basicParams.relationStatus = 0;
         basicParams.isLeaf =this.activeName==='third'?1:null
        this.isDialog = true
        listEnumDetailUnLink(basicParams).then((res) => {
          this.isDialog = false
          if (res.data.code === 200) {
             this.tableDataDialog = res.data.data;
          }
        });
    },
    handleJc() { // 检查
      this.handleTab()
    }
  }
}
</script>

<style lang="less" scoped>
  /deep/.ck-filter-form .form-item-container{
    flex-grow: 0 !important;
  }
  .table-wraper{
    overflow: hidden;
    flex: 1;
    .title{
      text-align: center;
      line-height: 40px;
      background: #207ffa;
      color: white;
      border: 1px solid #efefef;
    }
    .list-box{
      overflow-y: auto;
      height: calc(100% - 42px);
    }
    .block{
      // min-height: 40px;
      // line-height: 40px;
      border-left: 1px solid #efefef;
      border-right: 1px solid #efefef;
      border-bottom: 1px solid #efefef;
      padding: 5px 10px;
      text-align: center;
    }
  }
</style>
